package com.lexian.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lexian.entity.Category;
import com.lexian.entity.Goods;
import com.lexian.entity.Store;
import com.lexian.mapper.StoreMapper;
import com.lexian.service.StoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lexian.utils.CommonResponse;
import com.mysql.cj.protocol.Resultset;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 门店信息表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2021-01-19
 */
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {

    @Autowired
    private StoreService storeService;

    //获取所有门店信息
    @Override
    public List<Store> getInfo() {
        //查询门店所有信息
        List<Store> goodsList = new ArrayList<Store>();
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        List<Store> storeList = baseMapper.selectList(null);
        return storeList;
    }

    //添加门店
    @Override
    public CommonResponse addStore(Store store) {
        storeService.save(store);
        return CommonResponse.ok();
    }

    //查询门店状态
    @Override
    public long getStoreIdBy(long storeId) {
        QueryWrapper<Store> wrapper = new QueryWrapper<>();
        wrapper.eq("store_id",storeId);
        wrapper.eq("status",1);
        return storeService.getOne(wrapper).getStoreId();
    }
}
